home *** CD-ROM | disk | FTP | other *** search
- /* grog.c - a replacement for the afmtodit perl script that comes */
- /* with the GNU distribution of groff 1.07 */
- /* Written by Hildo Biersma on March 6, 1993 */
- /* GNU public license applies - please see the file COPYING for details. */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #include <limits.h> /* For PATH_MAX */
- #include <support.h> /* For findfile() and unx2dos() */
-
- /* Note that, since the script name has an extension, findfile() */
- /* ignores these extensions for afmtodit.pl */
- char *extensions[] = {"ttp", "tos", "prg", NULL };
-
- void main(int argc, char *argv[])
- {
- char *ptr, **arg_vector, script[PATH_MAX + 1];
- int counter;
-
- /* Build the argument vector */
- /* Note: arg_vector[0] and arg_vector[1] are filled in later */
- if ((arg_vector = malloc(sizeof(char *) * (argc + 3))) == NULL)
- {
- fprintf(stderr, "%s: out of memory\n", argv[0]);
- exit(1);
- }
- for (counter = 1; counter <= argc; counter++)
- arg_vector[counter + 1] = argv[counter];
-
- /* Try to run perl */
- ptr = findfile("afmtodit.pl", getenv("PATH"), extensions);
- if (ptr != NULL)
- {
- unx2dos(ptr, script);
- script[PATH_MAX] = 0x00;
- arg_vector[1] = script;
- arg_vector[0] = "perl";
- execvp("perl", arg_vector);
- }
-
- /* Give up */
- fprintf(stderr, "%s: cannot find perl script or interpreter\n", argv[0]);
- exit(1);
- } /* End of main() */
-